package com.moter.one.wyydemo1.service;

import com.moter.one.wyydemo1.entity.SongInfo;
import com.moter.one.wyydemo1.entity.UserInfo;
import com.moter.one.wyydemo1.mapper.SongInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SongInfoService {
    @Autowired
    private SongInfoMapper songInfoMapper;
    //根据播放量选择Top8的歌曲
    public List<SongInfo> selectSongInfoTop8Mapper(String type){
         return songInfoMapper.selectSongTop8Info(type);
    }
    //根据播放量选择Top8的歌曲
    public List<SongInfo> selectSongInfoTop8Mapper(){
        return songInfoMapper.selectSongTop8_Info();
    }
    //根据日期找最新Top5的歌曲
    public  List<SongInfo> selectSongInfoTop5Mapper(){return songInfoMapper.selectSongTop5Info();}
    //根据点赞找排名前10的歌曲
    public List<SongInfo> selectSongInfoTop10_Like_Mapper(){return songInfoMapper.selectSongTop10_Like_Info();}
    //根据收藏量找排名前10的歌曲
    public List<SongInfo> selectSongInfoTop10_Collected_Mapper(){return songInfoMapper.selectSongTop10_Collected_Info();}
    //根据日期和播放量找排名前10的歌曲
    public List<SongInfo> selectSongInfoTop10_NewSongs_Mapper(){return songInfoMapper.selectSongTop10_NewSongs_Info();}
    //根据SongInfo对象信息更新SongInfo
    public void UpdateSongInfo(SongInfo s){songInfoMapper.UpdateSongInfo(s);}
    //查询从(n-1)*9开始
    public List<SongInfo> queryPageInfo(Integer page,Integer limit){return songInfoMapper.queryPageSong(page,limit);}
    //插入歌曲
    public void insertSong(SongInfo songInfo){
        songInfoMapper.insertSongInfo(songInfo);
    }
    //查询所有
    public List<SongInfo> queryAll(){
        return songInfoMapper.queryAll();
    }
    //多条件查询
    public List<SongInfo> searchBy_id_name_singer(String lyrics,String song_name,String singer_name){
        return songInfoMapper.searchBy_id_name_singer(lyrics,song_name,singer_name);
    }
    //根据id删除歌曲
    public int deleteById(int song_id){
        return songInfoMapper.deleteById(song_id);
    }

    //多条件查询2
    public List<SongInfo> searchByItem(String item){
        System.out.println("item = " + item);
        return songInfoMapper.searchByItem(item);
    }
    //根据song_id修改点赞数
    public int UpdateLike(String song_id,Integer num){
        return songInfoMapper.UpdateSongLike(song_id,num);
    }

    //根据song_id修改收藏数
    public int UpdateCollected(String song_id,Integer num){
        return songInfoMapper.UpdateSongCollected(song_id,num);
    }

    //根据song_id查找歌曲
    public SongInfo selectById(int num) {
        return songInfoMapper.selectById(num);
    }
}
